// Copyright (c) 2009-2011, chunquedong
//
// This file is part of ChunMap project
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
//
// History:
//   2011-10-30  Jed Young  Creation
//

using [java]com.vividsolutions.jts.geom::Geometry as JGeometry
using [java]com.vividsolutions.jts.operation.overlay::OverlayOp as JOverlayOp
using chunmapModel

class OverlayOp
{
  Jts jts := Jts()

  static Int difference() { JOverlayOp.DIFFERENCE }
  static Int intersection() { JOverlayOp.INTERSECTION }
  static Int symdifference() { JOverlayOp.SYMDIFFERENCE }
  static Int union() { JOverlayOp.UNION }

  Geometry overlay(Geometry g1, Geometry g2, Int opCode)
  {
    jg := JOverlayOp.overlayOp(jts.toJts(g1), jts.toJts(g2), opCode)
    return jts.toCm(jg)
  }
}